import StatusNav from '@/components/school/statusNav';
import PageBody from '@/components/school/pageBody';
import RichText from '@/components/school/richtext';
import {mapGetters} from "vuex";
import * as ProductApi from '@/api/school/product.js';
import diyJson from '@/config/diy.js';
import {BASE_CONFIG} from "@/config/app";
export const mixins =
    {
      computed: mapGetters(['uid', 'userInfo', 'shareInfo', 'schoolId']),
      components: {
        StatusNav,
        PageBody,
        RichText
      },
      data() {
        return {
          title: '物品详情',
          userConcat: {
            show: false,
          },
          themConfig: diyJson.commonStyle,
          product: {},

          statusNavProperties: { // 筛选条件
            title: "二手物品详情",
            setStyle: diyJson.statusbar.setStyle,
            showLeft:true,
            showHome:true
          },
        };
      },

      onLoad: function (options) {
        let productNo = options.productNo
        this.product.productNo = productNo;
        this.getData(productNo);
      }
      ,

      methods: {
        getData(productNo) {
          ProductApi.productDetail(productNo).then(res => {
            this.product=res.data
          })
        },
        showLagerImg(url,urls){
          uni.previewImage({
            urls: urls, //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
            current: '', // 当前显示图片的http链接，默认是第一个
            success: function (res) {
            },
            fail: function (res) {
            },
            complete: function (res) {
            },
          })
        },
        copyLick(){

          uni.setClipboardData({
            data: BASE_CONFIG.H5WebHost+'/pages/school/product-idle/detail/index?productNo='+this.product.productNo,
            success: function () {
              uni.showToast({
                title: '分享链接已复制',
                icon: 'success',
                duration: 2000
              });
            }
          });
        }
        ,
        closeUserInfo(){

        },
        showConcatInfo(){
          this.$refs.actionSheet.open();
        },
        coloseConcatInfo(){
          this.$refs.actionSheet.close();
        },
        call(phone){
          uni.makePhoneCall({
            phoneNumber: phone // 电话号码
          });
        },
        copyWechat(id){
          uni.setClipboardData({
            data: id,
            success: function () {
              uni.showToast({
                title: '已复制：'+id,
                icon: 'success',
                duration: 2000
              });
            }
          });
        }
      },

      onReachBottom() {

      },
      onPullDownRefresh() {
        uni.stopPullDownRefresh();
      },
      onShareAppMessage() {
        return {
          title: '闲置二手详情',
          path: 'pages/school/product-idle/detail/index?productNo='+this.product.productNo, // 分享路径（推荐带参数）
          imageUrl: '' // 自定义分享图片（选填）
        }
      }
    }
